package io.renren.modules.generator.service.impl;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

import io.renren.modules.generator.dao.StudentDao;
import io.renren.modules.generator.entity.StudentEntity;
import io.renren.modules.generator.service.StudentService;
import io.renren.util.UUIDUtil;

/**
 * 
 * @author fanzc
 *
 */
@Service("studentService")
public class StudentServiceImpl extends BaseServiceImpl implements StudentService {
	private static final Logger LOGGER = Logger.getLogger(StudentServiceImpl.class);
	
	@Override
	public StudentEntity queryObject(String studentno) {
		return studentDao.queryObject(studentno);
	}
	
	@Override
	public List<StudentEntity> queryList(Map<String, Object> map) {
		return studentDao.queryList(map);
	}
	
	@Override
	public int queryTotal(Map<String, Object> map) {
		return studentDao.queryTotal(map);
	}
	
	@Override
	public void save(StudentEntity student) {
		student.setStudentno(UUIDUtil.getOrderIdByUUId());
		student.setMakedate(new Date());
		student.setModifydate(new Date());
		studentDao.save(student);
	}
	
	@Override
	public void update(StudentEntity student) {
		studentDao.update(student);
	}
	
	@Override
	public void delete(String studentno) {
		studentDao.delete(studentno);
	}
	
	@Override
	public void deleteBatch(String[] studentnos) {
		studentDao.deleteBatch(studentnos);
	}

	@Override
	public List<StudentEntity> commonQueryQueryList(Map<String, Object> map) {
		return studentDao.commonQueryQueryList(map);
	}

	/**
	 * 退学
	 * @param studentnos
	 * @return
	 */
	@Override
	public boolean dropout(String[] studentnos) {
		try {
			studentDao.dropout(studentnos);
		} catch (Exception e) {
			LOGGER.debug(e.getMessage());
			return false;
		}
		return true;
	}

	@Override
	public List<StudentEntity> findAllStudent() {
		return studentDao.findAllStudent();
	}
	
}